<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>



<f:subview id="news">
	<a4j:loadBundle var="msg" basename="messages_#{localManager.local}"></a4j:loadBundle>
	<h:form style="overflow:auto">

		<a4j:region>
			<rich:dataTable value="#{newsManager.dataList}" var="dataItem"
				 reRender="ds"
				id="newsList" onRowContextMenu="row=this; alert(this);"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				cellpadding="0" cellspacing="0" border="0" rows="20">

				<f:facet name="header">
					<h:outputText value="#{msg['kurier.zamowienia']}" />
				</f:facet>

				<rich:column width="25" sortBy="#{dataItem.id}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.id']}"/>
					</f:facet>
					<h:outputText value="#{dataItem.id}" />
				</rich:column>

				<rich:column width="25" sortBy="#{dataItem.dodalImie}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.imie']}" />
					</f:facet>
					<h:outputText value="#{dataItem.dodalImie}" />
				</rich:column>
				
				<rich:column width="25" sortBy="#{dataItem.dodalNazwisko}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.nazwisko']}" />
					</f:facet>
					<h:outputText value="#{dataItem.dodalNazwisko}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.dataDodania}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.data.dodania']}" />
					</f:facet>
					<h:outputText value="#{dataItem.dataDodania}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.tresc}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.news.tresc']}" />
					</f:facet>
					<h:outputText value="#{dataItem.tresc}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.jezyk}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.news.jezyk']}" />
					</f:facet>
					<h:outputText id="imieOutput" value="#{dataItem.jezyk}" />
				</rich:column>

				<rich:column>
					<a4j:commandLink ajaxSingle="true" id="editlink"
						action="#{newsManager.prepareEditData}"
						oncomplete="#{rich:component('editMPnews')}.show()">
						<h:graphicImage value="/images/edit.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{newsManager.editedData}" />
					</a4j:commandLink>
					<rich:toolTip for="editlink" value="#{msg['kurier.zlec.edit']}" />

					<a4j:commandLink ajaxSingle="true" id="deleteLink"
						oncomplete="#{rich:component('deleteMPnews')}.show()">
						<h:graphicImage value="/images/delete.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{newsManager.editedData}" />
					</a4j:commandLink>
					<rich:toolTip for="deleteLink" value="#{msg['kurier.zlec.usun']}" />
				</rich:column>

				<f:facet name="footer">
					<rich:datascroller id="ds" align="center" for="newsList"
					 maxPages="20" />
				</f:facet>
			</rich:dataTable>
			
			<%-- <a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.dodaj']}" 
				action="#{newsManager.prepareAddData}"
				reRender="newsList"
				oncomplete="#{rich:component('addMPnews')}.show()">
			</a4j:commandButton> --%>
			<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.odswierz']}" 
				action="#{newsManager.refreshData}"
				reRender=" newsList">
			</a4j:commandButton>
			<rich:messages id="mymessages" globalOnly="true" style="color:red" />
		</a4j:region>
		</h:form>


		<rich:modalPanel id="editMPnews" domElementAttachment="parent"
			autosized="true" width="600" height="400">

			<f:facet name="header">
				<h:outputText id="editLabel" value="#{msg['kurier.zlec.edit']}" ></h:outputText>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink" />
					<rich:componentControl for="editMPnews" attachTo="hidelink"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<a4j:outputPanel  ajaxRendered="true">
					<h:panelGrid columns="3" border="0">

							<h:column>
							<h:outputLabel for="id" value="#{msg['kurier.id']}:" />
						</h:column>
						<h:inputText size="35" id="id"   value="#{newsManager.editedData.id}" disabled="true"/>
						<h:column>
							<h:message style="color:red" for="id" />
						</h:column>
						
						
						<h:column>
							<h:outputLabel for="idPracownika" value="#{msg['kurier.dodal']}:" />
						</h:column>
						<h:column>
						<h:inputText size="35" id="idPracownika"   value="#{newsManager.editedData.dodalImie} #{newsManager.editedData.dodalNazwisko} " disabled="true"/>
						</h:column>
						<h:column>
							<h:message style="color:red" for="idPracownika" />
						</h:column>

						<h:column>
							<h:outputLabel for="dataDodania" value="#{msg['kurier.data.dodania']}:" />
						</h:column>
						<h:column>
						<h:inputText size="35" id="dataDodania"   value="#{newsManager.editedData.dataDodania}" disabled="true"/>
						</h:column>
						<h:column>
							<h:message style="color:red" for="dataDodania" />
						</h:column>
						
						
						<h:column>
						</h:column>
						<h:column>
							<rich:editor  width="700" height="500" theme="advanced" value="#{newsManager.editedData.tresc}" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="dataDodania" />
						</h:column>
						

						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.zapisz']}" 
							action="#{newsManager.editData}"
							reRender=" newsList"
							oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editMPnews')}.hide();}">
						</a4j:commandButton>
						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.anuluj']}" 
							onclick="#{rich:component('editMPnews')}.hide(); return false;" />

					</h:panelGrid>
						<rich:messages id="mymessages" globalOnly="true" style="color:red" />
				</a4j:outputPanel>
				
			</h:form>

		</rich:modalPanel>

		<rich:modalPanel id="addMPnews" domElementAttachment="parent"
			autosized="true" width="600" height="400">
			<f:facet name="header">
				<h:outputText id="addLabel" value="#{msg['kurier.zlec.dodaj']}" ></h:outputText>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink1" />
					<rich:componentControl for="addMPnews" attachTo="hidelink1"
						operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<a4j:outputPanel ajaxRendered="true">
					<h:panelGrid columns="3" border="0" >
					
						<h:column>
							<h:outputLabel for="id" value="#{msg['kurier.id']}:" />
						</h:column>
						<h:inputText size="35" id="id"   value="#{newsManager.newData.id}" disabled="true"/>
						<h:column>
							<h:message style="color:red" for="id" />
						</h:column>
						
						
						<h:column>
							<h:outputLabel for="idPracownika" value="#{msg['kurier.dodal']}:" />
						</h:column>
						<h:column>
						<h:inputText size="35" id="idPracownika"   value="#{newsManager.newData.dodalImie} #{newsManager.newData.dodalNazwisko} " disabled="true"/>
						</h:column>
						<h:column>
							<h:message style="color:red" for="idPracownika" />
						</h:column>

						<h:column>
							<h:outputLabel for="dataDodania" value="#{msg['kurier.data.dodania']}:" />
						</h:column>
						<h:column>
						<h:inputText size="35" id="dataDodania"   value="#{newsManager.newData.dataDodania}" disabled="true"/>
						</h:column>
						<h:column>
							<h:message style="color:red" for="dataDodania" />
						</h:column>
						
						
						<h:column>
						</h:column>
						<h:column>
							<rich:editor  width="700" height="500" theme="advanced" value="#{newsManager.newData.tresc}" />
						</h:column>
						<h:column>
							<h:message style="color:red" for="dataDodania" />
						</h:column>
						
						

						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.zapisz']}"
							action="#{newsManager.addData}" reRender="newsList"  
							oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('addMPnews')}.hide();}"/>
						<a4j:commandButton styleClass="RFbutton" value="#{msg['kurier.zlec.edit.anuluj']}"
							onclick="#{rich:component('addMPnews')}.hide(); return false;" />
					</h:panelGrid>
					<rich:messages id="mymessages" globalOnly="true" style="color:red" />
				</a4j:outputPanel>
			</h:form>
		</rich:modalPanel>

		<rich:modalPanel id="deleteMPnews" autosized="true" width="200">
			<f:facet name="header">
				<h:outputText value="#{msg['kurier.zlec.usun']}"
					style="padding-right:15px;" />
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink2" />
					<rich:componentControl for="deleteMPnews"
						attachTo="hidelink2" operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:form>
				<table width="100%">
					<tbody>
						<tr>
							<td align="center" width="50%"><a4j:commandButton styleClass="RFbutton"
									value="#{msg['kurier.zlec.tak']}" ajaxSingle="true"
									action="#{newsManager.deleteData}"
									oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('deleteMPnews')}.hide();}"
									reRender="newsList" />
							</td>
							<td align="center" width="50%"><a4j:commandButton styleClass="RFbutton"
									value="#{msg['kurier.zlec.edit.anuluj']}"
									onclick="#{rich:component('deleteMPnews')}.hide();return false;" />
							</td>
						</tr>
					</tbody>
				</table>
					<rich:messages id="mymessages" globalOnly="true" style="color:red" />
			</h:form>
		</rich:modalPanel>
		<a4j:status onstart="#{rich:component('wait')}.show()"
			onstop="#{rich:component('wait')}.hide()" />
		<rich:modalPanel id="wait" autosized="true" width="200" height="120"
			moveable="false" resizeable="false">
			<f:facet name="header">
				<h:outputText value="Processing" />
			</f:facet>
			<h:outputText value="Wait Please..." />
		</rich:modalPanel>




</f:subview>
